// 引入mock
import Mock from 'mockjs'
import qs from 'qs'
export default {
  // config 是请求配置对象
  hot: config => {
    const queryStr = qs.parse(config.url.split('?')[1]) || {}
    const limit = queryStr.limit || 10
    const brands = []
    for (let i = 0; i < limit; i++) {
      brands.push(Mock.mock({
        id: '@id',
        name: '@ctitle(5,10)',
        place: '@city',
        picture: `http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/brand_goods_${i % 5 + 1}.jpg`
      }))
    }
    return {
      msg: '查询品牌成功',
      result: brands
    }
  },
  // 广告区域
  banner: config => {
    const list = []
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        id: '@id',
        imgUrl: `http://zhoushugang.gitee.io/erabbit-client-pc-static/images/b${i + 1}.jpg`,
        hrefUrl: '/#/'
      }))
    }
    return {
      msg: '查询广告区域成功',
      result: list
    }
  }
}
